import { Context } from "telegraf";
import MessageStore from "../service/MessageStore";
import Parser from "./Parser";
import { CommandFactory, Keys } from "../commands/CommandFactory";

export default class Processor {
    async text(ctx: Context) {
        const parser: Parser = new Parser(ctx);
        MessageStore.setValue(parser.getMessageText());
        if(parser.isValidCommand()){
            const result: string | null = await new CommandFactory(ctx)
                .getCommand(parser.getCommandName() as Keys)
                .execute();
            if(result) {
                ctx.reply(result);
            }
        }
    }
}